<input type="hidden" value="ENTIER" name="site[<?PHP echo $nb;?>]<?PHP if(isset($voxbloc)) echo '[bloc]['.$voxbloc.']';?>[question][<?PHP echo $question['id_question'];?>][type]" />
<div class="input_entier" style="clear:both;">
	<label><?PHP echo $question['libelle_question'];?></label>
	<?PHP // parcours des r�ponses pour l'ajout des reponses
		$id_reponse = null;
		$script = '';
		$ajoutFait = '';
		$modifFait = '';
		
		foreach ($question['reponses'] as $reponse) {
			// on prend le premier id en m�moire
			if($id_reponse == null && $reponse['id_reponse'] != null) {
				$id_reponse = $reponse['id_reponse'];
				$modifFait = "baseDeFait[$nb]['site".$nb."_reponse_".$id_reponse."'].reponses = new Array();";
			}
			$modifFait .= "baseDeFait[$nb]['site".$nb."_reponse_".$id_reponse."'].reponses['site".$nb."_reponse_".$reponse['id_reponse']."'] = {min:".$reponse['valeur_min'].", max:".$reponse['valeur_max'].", defaut:'".$reponse['libelle_statut_par_defaut']."'};";
			$ajoutFait .= "ajouterFait(".$nb.", 'site".$nb."_reponse_".$reponse['id_reponse']."', document.getElementById('site".$nb."_reponse_$id_reponse'));\n";
			$ajoutFait .= "baseDeFait[$nb]['site".$nb."_question_".$question['id_question']."_reponses'].push(document.getElementById('site".$nb."_reponse_$id_reponse'));\n";
			if($id_reponse != null) {
				// on parcours les actions associ�s � cette r�ponse
				foreach ($reponse['actions'] as $action) {
					if($action['id_reponse'] != null) {
						if($action['active_question']) {
							$script .= "ajouterRegle(function(){return $(baseDeFait[".$nb."]['site".$nb."_question_".$question['id_question']."']).is(':visible') && baseDeFait[".$nb."]['site".$nb."_reponse_$id_reponse'].value >= ".$reponse['valeur_min']." && baseDeFait[".$nb."]['site".$nb."_reponse_$id_reponse'].value <= ".$reponse['valeur_max'].";}, function(){afficherElement(".$nb.", 'site".$nb."_question_".$action['id_question']."');})\n";
						}
						else {
							$script .= "ajouterRegle(function(){return $(baseDeFait[".$nb."]['site".$nb."_question_".$question['id_question']."']).is(':visible') && baseDeFait[".$nb."]['site".$nb."_reponse_$id_reponse'].value >= ".$reponse['valeur_min']." && baseDeFait[".$nb."]['site".$nb."_reponse_$id_reponse'].value <= ".$reponse['valeur_max'].";}, function(){cacherElement(".$nb.", 'site".$nb."_question_".$action['id_question']."');})\n";
						}
					}
				}
				// on parcours également son tableau de change_statut
				foreach($reponse['change_statut'] as $change_statut) {
					// on ajoute au script le changement de statut
					$modifFait .= "ajouterRegle(function(){return $(baseDeFait[".$nb."]['site".$nb."_question_".$question['id_question']."']).is(':visible') && baseDeFait[".$nb."]['site".$nb."_reponse_$id_reponse'].value >= ".$reponse['valeur_min']." && baseDeFait[".$nb."]['site".$nb."_reponse_$id_reponse'].value <= ".$reponse['valeur_max'].";}, function(){changerStatut(".$nb.", 'site".$nb."_reponse_".$change_statut['id_reponse_statut_change_par']."', '".$change_statut['libelle_statut']."', ".$change_statut['priorite'].");});\n";
				}
			}
		}
	?>
	<span>
		<input name="site[<?PHP echo $nb; ?>]<?PHP if(isset($voxbloc)) echo '[bloc]['.$voxbloc.']';?>[question][<?PHP echo $question['id_question']; ?>][val]" <?PHP if($id_reponse != null) echo 'id="site'.$nb.'_reponse_'.$id_reponse.'"'; ?> type="number" onchange="appliquerMoteur(<?PHP echo $nb;?>)" />
	</span>
	<script type="text/javascript">
		<?PHP
			echo $ajoutFait;
			echo $script;
			echo $modifFait;
		?>
	</script>
</div>

